home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 1.4 KB | 36 lines | [TEXT/GEOL] |
- Item 0457693 24-Aug-90 11:41PDT
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: MACAPP.TECH$ MacApp Technical
- POWERUP.ENG Power Up Software,PRT
-
- Sub: RE>Multiple Inheritance Q
-
- Attn: MacApp Tech
- Attn: James Plamondon
- SentBy: Larry Rosenstein
- Reply to: RE>Multiple Inheritance Ques
- I think TCardFace and TCardBack are reasonable classes. TCard, however, is
- not a kind of TCardFace or TCardBack, and shouldn't inherit from either. To
- me, this is a clear case where you wouldn't use multiple inheritance.
-
- A card contains a face and back, and an instance of TCard should have fields
- for its face and back. If the program isn't allowed to see the face, then its
- face field would be NIL. (The dealer would assign random numbers to the cards
- so that when a card is turned over it can be given its proper TCardFace
- instance.)
-
- Geoff's example is probably the more likely case where multiple inheritance
- would be used. (Combining behavior for more than one existing class.) Even
- then multiple inheritance isn't necessary; one could inherit directly from the
- "primary" class and delegate behavior to the "secondary" classes. This allows
- you to reuse the code of the secondary classes.
-
- Inheritance should only be used for expressing type relationships between
- classes. It shouldn't be used just as a mechanism for reusing code.
-
- Larry Rosenstein
-
-
-